/* spearl/include/spearl/klist.h 
 * 
 * This file is part of spearl. 
 * 
 * Spearl is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version. 
 * 
 * Spearl is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with spearl. If not, see <https://www.gnu.org/licenses/>
 */ 




#ifndef __SPEARL_KLIST_H
#define __SPEARL_KLIST_H

#include <spearl/sys.h>


struct spl_klist_node {
	struct spl_klist_node *next, *prev;
};

void spl_klist_init(struct spl_klist_node *head);

void spl_klist_add(struct spl_klist_node *head, struct spl_klist_node *n);
void spl_klist_del(struct spl_klist_node *head, struct spl_klist_node *will_del);

#define spl_klist_empty(list) ((list)->next == (list))
#define SPL_KLIST_NODE_INIT(__node) { 	\
	.next = __node,  		\
	.prev = __node,			\
}

#ifndef container_of
#define container_of(ptr, type, member) ((type *) ((void *) (ptr) - offsetof(type, member)))
#endif

#endif

